<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>缓存服务器池中所有服务器统计信息</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="memcache.get.html">« Memcache::get</a></li>
      <li style="float: right;"><a href="memcache.getserverstatus.html">Memcache::getServerStatus »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.memcache.html">Memcache</a></li>
    <li>缓存服务器池中所有服务器统计信息</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="memcache.getextendedstats" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Memcache::getExtendedStats</h1>
  <p class="verinfo">(PECL memcache &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Memcache::getExtendedStats</span> &mdash; <span class="dc-title">缓存服务器池中所有服务器统计信息</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-memcache.getextendedstats-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>Memcache::getExtendedStats</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$type</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$slabid</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$limit</code><span class="initializer"> = 100</span></span>): <span class="type">array</span></div>


  <p class="para rdfs-comment">
   <span class="function"><strong>Memcache::getExtendedStats()</strong></span> 返回一个二维关联数据的服务器统计信息。数组的key由host:port方式
   组成，无效的服务器返回的统计信息被设置为false，同样的，你可以使用函数<span class="function"><strong>memcache_get_extended_stats()</strong></span>。
  </p>

  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    这个函数在Memcache2.0.0版本加入。
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    (译注)获取Memcache内所有数据方法：首先使用getExtendedStats(&#039;slabs&#039;)获取到每个服务器上活动slabs分块的id， 然后
    使用getExtendedStats(&#039;cachedump&#039;, $slabid, $limit)来获取每个slab里面缓存的项，其中$slabid是slab分块id， $limit指
    期望获取其中的多少条记录。
   </p>
  </p></blockquote>
 
 </div>


 <div class="refsect1 parameters" id="refsect1-memcache.getextendedstats-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">type</code></dt>

     <dd>

      <p class="para">
      期望抓取的统计信息类型，可以使用的值有{reset, malloc, maps, cachedump, slabs, items, sizes}。
      通过memcached协议指定这些附加参数是为了方便memcache开发者(检查其中的变动)。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">slabid</code></dt>

     <dd>

      <p class="para">
      用于与参数<code class="parameter">type</code>联合从指定slab分块拷贝数据，cachedump命令会完全占用服务器通常用于
      比较严格的调试。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">limit</code></dt>

     <dd>

      <p class="para">
      用于和参数<code class="parameter">type</code>联合来设置cachedump时从服务端获取的实体条数。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-memcache.getextendedstats-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
  返回一个二维关联数组的服务器统计信息或者在失败时返回<strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-memcache.getextendedstats-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4368">
    <p><strong>示例 #1 <span class="function"><strong>Memcache::getExtendedStats()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;$memcache_obj&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Memcache</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$memcache_obj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'memcache_host'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$memcache_obj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">'failed_host'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">11211</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$stats&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$memcache_obj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getExtendedStats</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$stats</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [memcache_host:11211] =&gt; Array
        (
            [pid] =&gt; 3756
            [uptime] =&gt; 603011
            [time] =&gt; 1133810435
            [version] =&gt; 1.1.12
            [rusage_user] =&gt; 0.451931
            [rusage_system] =&gt; 0.634903
            [curr_items] =&gt; 2483
            [total_items] =&gt; 3079
            [bytes] =&gt; 2718136
            [curr_connections] =&gt; 2
            [total_connections] =&gt; 807
            [connection_structures] =&gt; 13
            [cmd_get] =&gt; 9748
            [cmd_set] =&gt; 3096
            [get_hits] =&gt; 5976
            [get_misses] =&gt; 3772
            [bytes_read] =&gt; 3448968
            [bytes_written] =&gt; 2318883
            [limit_maxbytes] =&gt; 33554432
        )

    [failed_host:11211] =&gt; false
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-memcache.getextendedstats-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="memcache.getversion.html" class="function" rel="rdfs-seeAlso">Memcache::getVersion()</a> - 返回服务器版本信息</span></li>
    <li class="member"><span class="function"><a href="memcache.getstats.html" class="function" rel="rdfs-seeAlso">Memcache::getStats()</a> - 获取服务器统计信息</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>